package com.zhentao.tot.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.zhentao.tot.domain.WmUser;
import com.zhentao.tot.service.IWmUserService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 自媒体用户信息Controller
 * 
 * @author ruoyi
 * @date 2025-04-18
 */
@RestController
@RequestMapping("/wm_user")
public class WmUserController extends BaseController
{
    @Autowired
    private IWmUserService wmUserService;

    /**
     * 查询自媒体用户信息列表
     */
    @RequiresPermissions("tot:wm_user:list")
    @GetMapping("/list")
    public TableDataInfo list(WmUser wmUser)
    {
        startPage();
        List<WmUser> list = wmUserService.selectWmUserList(wmUser);
        return getDataTable(list);
    }

    /**
     * 导出自媒体用户信息列表
     */
    @RequiresPermissions("tot:wm_user:export")
    @Log(title = "自媒体用户信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmUser wmUser)
    {
        List<WmUser> list = wmUserService.selectWmUserList(wmUser);
        ExcelUtil<WmUser> util = new ExcelUtil<WmUser>(WmUser.class);
        util.exportExcel(response, list, "自媒体用户信息数据");
    }

    /**
     * 获取自媒体用户信息详细信息
     */
    @RequiresPermissions("tot:wm_user:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(wmUserService.selectWmUserById(id));
    }

    /**
     * 新增自媒体用户信息
     */
    @RequiresPermissions("tot:wm_user:add")
    @Log(title = "自媒体用户信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WmUser wmUser)
    {
        return toAjax(wmUserService.insertWmUser(wmUser));
    }

    /**
     * 修改自媒体用户信息
     */
    @RequiresPermissions("tot:wm_user:edit")
    @Log(title = "自媒体用户信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WmUser wmUser)
    {
        return toAjax(wmUserService.updateWmUser(wmUser));
    }

    /**
     * 删除自媒体用户信息
     */
    @RequiresPermissions("tot:wm_user:remove")
    @Log(title = "自媒体用户信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(wmUserService.deleteWmUserByIds(ids));
    }
}
